package com.macro.mall.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.e.SysKeyEntDTO;
import com.macro.mall.model.BasicKeyText;
import com.macro.mall.query.BasicKeyTextQuery;
import com.macro.mall.service.SysKeysService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sys/key")
public class SysKeyController {
    @Autowired
    private SysKeysService sysKeysService;

    @RequestMapping("/list")
    public CommonResult list(@RequestBody BasicKeyTextQuery query) {
        return sysKeysService.list(query);
    }

    @RequestMapping("/get")
    public CommonResult get(@RequestBody SysKeyEntDTO sysKeyEntDTO) {
        return null;
    }


    /***
     * 新增
     * @param sysKeyEntDTO
     * @return
     */
    @PostMapping("/add")
    public CommonResult add(@RequestBody BasicKeyText sysKeyEntDTO) {
        return sysKeysService.modify(sysKeyEntDTO);
    }


    /***
     * 修改
     * @param sysKeyEntDTO
     * @return
     */
    @PutMapping("/modify")
    public CommonResult modify(@RequestBody BasicKeyText sysKeyEntDTO) {
        return sysKeysService.modify(sysKeyEntDTO);
    }

    @RequestMapping("/setStatus")
    public CommonResult setStatus(@RequestBody BasicKeyText sysKeyEntDTO) {
        return sysKeysService.modify(sysKeyEntDTO);
    }

    @RequestMapping("/setOff")
    public CommonResult setOff(@RequestBody SysKeyEntDTO sysKeyEntDTO) {
        return null;
    }


    @DeleteMapping("/{id}")
    public CommonResult delete(@PathVariable(value = "id")Long id){
        return sysKeysService.delete(id);
    }
}
